package com.zxy.hotel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zxy.hotel.entity.Vip;
import com.zxy.hotel.mapper.VipMapper;
import com.zxy.hotel.service.VipService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jiusi
 * @since 2021-12-12
 */
@Service
public class VipServiceImpl extends ServiceImpl<VipMapper, Vip> implements VipService {

    @Autowired
    private VipMapper vipMapper;

    @Override
    public List<Vip> fuzzy(String cardId) {
        QueryWrapper<Vip> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("cardid", cardId);
        return vipMapper.selectList(queryWrapper);
    }

    @Override
    public Integer register(String name, String cardId, String phone) {
        Vip vip = new Vip();
        vip.setName(name);
        vip.setCardid(cardId);
        vip.setPhone(phone);
        vip.setLevel("普通会员");
        vip.setDiscount(99);
        vip.setPoints(0);
        return vipMapper.insertOne(vip);
    }
}
